package com.cxb.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageButton;

/**
 * @ClassName: ImageTextButton
 * @Description: 带文字的图片按钮
 * @author 杨瑜 45154139@qq.com
 * @date 2013-9-23 下午5:46:06
 * 
 */
public class ImageTextButton extends ImageButton {
	private String _text = "";
	private int _color = 0;
	private float _textsize = 0f;
	private int textX = 0, textY = 0;

	public ImageTextButton(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void setText(String text) {
		this._text = text;
	}

	public void setTextX(int x) {
		this.textX = x;
	}

	public void setTextY(int y) {
		this.textY = y;
	}

	public void setColor(int color) {
		this._color = color;
	}

	public void setTextSize(float textsize) {
		this._textsize = textsize;
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Paint paint = new Paint();
		paint.setTextAlign(Paint.Align.CENTER);
		paint.setColor(_color);
		paint.setTextSize(_textsize);
		canvas.drawText(_text, textX, textY, paint);
	}
}